class_name CampSystem
extends BaseSystem

#region 属性
#endregion
#region 字段
#endregion
#region 信号
#endregion

#region 基类方法
func init_system():
	super.init_system()
#endregion
#region 公共方法
func get_target(camp_types:Array[GameEnum.Camp],pos:Vector2 = Vector2.ZERO,is_sort:bool = false,count:int = -1,radius:float = 0) -> Array:
	var targets:Array = []
	for camp_type in camp_types:
		var group_name:String = GameEnum.Camp.keys()[camp_type]
		if get_tree().has_group(group_name):
			targets.append_array(get_tree().get_nodes_in_group(group_name))
	if targets.size() > 0:
		if is_sort:
			targets.sort_custom(func (a,b):return (a.global_position - pos).length() < (b.global_position - pos).length())
		if radius > 0:
			targets = targets.filter(func (x):return (x.global_position - pos).length() <= radius)
		count = targets.size() if count < 0 else count
		return targets.slice(0,count)
	else:
		return []
func group_add(camp_type:GameEnum.Camp, item):
	var group_name:String = GameEnum.Camp.keys()[camp_type]
	item.add_to_group(group_name)
func group_remove(camp_type:GameEnum.Camp,item):
	var group_name:String = GameEnum.Camp.keys()[camp_type]
	item.remove_from_group(group_name)
#endregion
#region 私有方法
#endregion
#region 生命周期函数
#endregion
